import com.gitee.chessboard.jdbc.JdbcManager;
import com.gitee.chessboard.jdbc.executor.SqlExecutor;
import com.gitee.chessboard.manager.DefaultDictionaryManager;
import com.gitee.chessboard.model.dictionary.Dictionary;
import com.gitee.chessboard.parser.DefaultEnumDictionaryParser;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import parser.Enumerate;

/**
 * 删除
 * @author zll
 */
public class DictionaryDeleteTest {

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
        SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(
		        DictionaryDeleteTest.class.getClassLoader().getResourceAsStream("mybatis.xml"));
        Configuration configuration = sqlSessionFactory.getConfiguration();
        PooledDataSource dataSource = (PooledDataSource) configuration.getEnvironment().getDataSource();
        JdbcManager jdbcManager = new JdbcManager(
                dataSource.getDriver()
                , dataSource.getUrl()
                , dataSource.getUsername()
                , dataSource.getPassword());
        jdbcManager.setMybatisSqlSessionFactory(sqlSessionFactory);
        DefaultDictionaryManager manager = new DefaultDictionaryManager(jdbcManager);
        DefaultEnumDictionaryParser enumDictionaryParser = new DefaultEnumDictionaryParser(manager);

        SqlExecutor sqlExecutor = jdbcManager.getSqlExecutor();

        Dictionary parser = enumDictionaryParser.parser(Enumerate.class);
        parser.delSelf();

    }

}
